#include "protheus.ch"

User Function AltMarca()
Local cAlias := "SC5"
Local cNroPed

dbSelectArea(cAlias)
(cAlias)->(dbSetOrder())
(cAlias)->(dbSetFilter({|| SC5->C5_EMISSAO >= CToD("01/01/2009") .AND. SC5->C5_EMISSAO <= CToD("31/12/2009") .AND. SC5->C5_CLIENTE = "052399"}, "FILTRO"))
(cAlias)->(dbGoTop())

While (cAlias)->(!EOF())
    cNroPed := SubStr(RTrim((cAlias)->C5_PEDCLI), 1, 1)
    
	IF cNroPed = "5" .OR. cNroPed = "6" 
		RecLock(cAlias, .F.)
			(cAlias)->C5_MARCA = "SUPER"
		MsUnlock()
	ElseIF cNroPed = "5" .OR. cNroPed = "6" 
		RecLock(cAlias, .F.)
			(cAlias)->C5_MARCA = "SAMS"
		MsUnlock()
	EndIF
	
	(cAlias)->(dbSkip())
EndDo

(cAlias)->(dbCloseArea())
Return